package com.demo.behavioral.iterator;

public class FastIterator  implements MyIterator{
	
	private MyCollection collection;
	
	private int pos = -1;  
	
	public FastIterator(MyCollection collection){
		this.collection = collection;
	} 

	public Object next() {
		if(pos<collection.size()-1){  
            pos++;  
        }  
        return collection.get(pos);  
	}

	public boolean hasNext() {
       if(pos<collection.size()-1){  
            return true;  
        }else{  
            return false;  
        }  
	}

}
